package com.bankfourfactor.nanyun;

import java.io.IOException;
import java.net.URL;
import java.security.Provider;
import java.security.Security;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;

import com.bankfourfactor.BankCarFactoryConstant;
import com.ny.lib.NyPropertiesUtil;
import com.ny.lib.NySignatureData;
import com.ny.lib.NySignatureStrUtil;
import com.seek.model.entity.TCustomerCard;

public class NyVerificationBank {
//	public  String test() {
//		Map<String,String>data=new HashMap<String, String>();
//		String priKey = BankCarFactoryConstant.NANYUN_PRIVATE_KEY;//从配置文件中获取私钥
//		String url = BankCarFactoryConstant.NANYUN_URL;//从配置文件中获取银行卡验证的url
//		String merchId=BankCarFactoryConstant.NANYUN_MERID;//商户号(商户可改为自己的商户号)
//		String version = BankCarFactoryConstant.NANYUN_VERSION;//版本号
//		data.put("version", version);
//		data.put("merId", merchId);
//		data.put("transDate",  new SimpleDateFormat("yyyyMMdd").format(new Date()));//交易日期(yyyyMMdd)
//		data.put("transType",  "10");
//		String seq =  String.valueOf(System.currentTimeMillis());//流水号
//		data.put("seqId",  seq);//流水号
//		data.put("transTime", new SimpleDateFormat("HHmmss").format(new Date()));//交易时间(hhmmss)
//		
//		//TODO: 请填写真实卡信息
//		data.put("cardNo", "626666666666666666");//银行卡号
//		data.put("name", "小张");//姓名
//		data.put("certNo", "31000000000000000");//身份证号
//		data.put("phone", "11111111111");//手机号
//		
//		
//		
//		NySignatureData signatureData = new NySignatureData();
//		String info=NySignatureStrUtil.getBankSignatureString(data,NyBase.encoding);
//		String signature = signatureData.sign(info, priKey);
//		data.put("sign", signature);
//		Map<String, String> resmap = NyBase.submitUrl(data, url);
//		System.out.println("请求报文=["+data.toString()+"]");
//		System.out.println("应答报文=["+resmap.toString()+"]");
//	}
	
	public static void test(){
				System.out.println("-------列出加密服务提供者-----");
				Provider[] pro = Security.getProviders();
				for (Provider p : pro) {
					System.out.println("Provider:" + p.getName() + " - version:" + p.getVersion());
					System.out.println(p.getInfo());
				}
				System.out.println("");
				System.out.println("-------列出系统支持的消息摘要算法：");
				for (String s : Security.getAlgorithms("MessageDigest")) {
					System.out.println(s);
				}
				System.out.println("-------列出系统支持的生成公钥和私钥对的算法：");
				for (String s : Security.getAlgorithms("KeyPairGenerator")) {
					System.out.println(s);
				}
	}
	
    static void printResources(String n) {
		Enumeration<URL> e;
		try {
			e = NyVerificationBank.class.getClassLoader().getResources(n);
			if (!e.hasMoreElements()) {
				System.out.println(n + " not found!");
			} else {
				System.out.println(n + " found as:");
				while (e.hasMoreElements()) {
					System.out.println("    " + e.nextElement());
				}
			}
		} catch (IOException e1) {
			e1.printStackTrace();
		}
    }
}
